//
//  GGDeviceViewController.m
//  DDLock
//
//  Created by ios on 2017/12/25.
//  Copyright © 2017年 saiyi. All rights reserved.
//

#import "GGDeviceViewController.h"
#import "GGDeviceNoEquimentView.h"
#import "GGDeviceCell.h"

@interface GGDeviceViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) GGDeviceNoEquimentView *noDeviceView;

@end

@implementation GGDeviceViewController

static NSString * const GGDeviceCellID = @"GGDeviceCell";

#pragma mark - getter

- (GGDeviceNoEquimentView *)noDeviceView {
    if (_noDeviceView == nil) {
        _noDeviceView = [GGDeviceNoEquimentView viewFromXIB];
        [self.view addSubview:self.noDeviceView];
        
    }
    return _noDeviceView;
}


- (void)setDidLoad {
     [super setDidLoad];
    
    self.title = @"设备";
    
//    [self _setAddNoDeviceView];
    [self _setDevicesTableView];
    
    [self _setBarButtonItem];
    
}

#pragma mark - private

// 无设备
- (void)_setAddNoDeviceView {
    
    [self.noDeviceView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(164 * kScaleH);
        make.centerX.equalTo(self.view.mas_centerX);
        make.left.right.equalTo(self.view);
    }];
}

// 有设备
- (void)_setDevicesTableView {
    
    [self setAddTableView:UITableViewStylePlain frame:self.view.frame target:self];

    [self.tableView registerNib:[UINib nibWithNibName:GGDeviceCellID bundle:nil] forCellReuseIdentifier:GGDeviceCellID];
}

- (void)_setBarButtonItem {
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"add"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(clickAddDevice)];
    
}


#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    GGDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:GGDeviceCellID];
    
    
    return cell;
    
}


#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [GGDeviceCell cellHeight];
}


#pragma mark - target

// 添加设备
- (void)clickAddDevice {
    
    
    
}

@end
